home *** CD-ROM | disk | FTP | other *** search
- Path: news1.h1.usa.pipeline.com!usenet
- From: grantp@usa.pipeline.com(Pete)
- Newsgroups: comp.lang.c++
- Subject: Re: QUESTION:Random Numbers, etc
- Date: 24 Feb 1996 20:20:58 GMT
- Organization: Kalevi, Inc.
- Message-ID: <4gnrva$m08@news1.usa.pipeline.com>
- NNTP-Posting-Host: pipe11.h1.usa.pipeline.com
- X-PipeUser: grantp
- X-PipeHub: usa.pipeline.com
- X-PipeGCOS: (Pete)
- X-Newsreader: Pipeline USA v3.3.0
-
- On Feb 24, 1996 19:39:56 in article <QUESTION:Random Numbers, etc>,
- 'garlans@usa.pipeline.com(White Shade)' wrote:
-
-
- >Hi, I'm a bit new to C/C++ programming. I have Microsoft Visual C++ 1.52,
- >and I'm trying to convert a few of my Basic programs to C so they'll run a
-
- >lot faster. I need to know how to get a random number starting from one
- and
- >ending at a certain number, like Basics a=int(rnd(1)*#)+1 or something...
-
- >
- >Oh yeah, I can't check this group very often, so could you send replies to
-
- >my e-mail address, GARLANS@USA.PIPELINE.COM ? Thanks...
- >
- Use the library function rand. But, be aware that it returns only
- a pseudo-random number (as does the random generator in VB).
- Also, you need to initialize the random number generator, typically
- at the begininning of your program. Function srand is for that purpose.
- Look in your on-line docs for details.
-
- --
- Pete Grant
- Kalevi, Inc.
- Software Engineering & development
-